/**
 * 就是数组的rotate操作
 * 但实际上不用，直接输出即可
 */
#include <bits/stdc++.h>
#include <bits/extc++.h>
using namespace std;

using llt = long long;
using vi = vector<int>;
using vll = vector<llt>;
using pii = pair<int, int>;
using pll = pair<llt, llt>;


int N, K;
vi A;


void work(){
    cin >> N >> K;
    A.assign(N, 0);
    for(auto & i : A) cin >> i;
    for(int i=N-K;i<N;++i) cout << A[i] << " ";
    for(int i=0;i<N-K;++i) cout << A[i] << " ";
    cout << endl;
    return;
}


int main(){
#ifndef ONLINE_JUDGE
    freopen("z.txt", "r", stdin);
#endif
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);	
    
    int nofkase = 1;
	// cin >> nofkase;
	while(nofkase--) work();
	return 0;
}